package cn.gok.util;

import java.sql.*;
import java.util.concurrent.Executor;

/**
 * @ClassName JDBCUtils
 * @Description TODO
 * @Author HP
 * @Date 9:21 2022/7/15
 * @Version 1.0
 **/
public class JDBCUtils {
    public static void main(String[] args) throws SQLException {
        String username ="root";
        String password = "root";
        String url = "jdbc:mysql://localhost:3306/my";
        String sql = "select * from user";
        Connection con = null;
        PreparedStatement ps = null;
        ResultSet rs = null;
        try {
            Class.forName("com.mysql.jdbc.Driver");
            con = DriverManager.getConnection(url,username,password);
            ps = con.prepareStatement(sql);
            rs = ps.executeQuery(sql);
            while (rs.next()){
                System.out.println(rs.getInt(1)+rs.getString(2)+rs.getInt(3));
            }
        } catch (Exception e) {
            e.printStackTrace();
        }finally {
            rs.close();
            ps.close();
            con.close();
        }
    }


}
